package com.kyivmohyla.kma2.server.proxy;

import com.kyivmohyla.kma2.ImportOrder;
import com.kyivmohyla.kma2.model.*;
import com.kyivmohyla.kma2.shared.model.*;

public class Proxy {

    public static Customer createFromUICustomer(UICustomer uiCustomer) {
        Customer customer = new Customer();
        customer.setCustomerId(uiCustomer.getCustomerId());
        customer.setFirstName(uiCustomer.getFirstName());
        customer.setLastName(uiCustomer.getLastName());
        customer.setPhone(uiCustomer.getPhone());
        customer.setEmail(uiCustomer.getEmail());
        customer.setAddress(uiCustomer.getAddress());
        return customer;
    }

    public static Order createFromUIOrder(UIOrder uiOrder) {
        Order order = new Order();
        order.setOrderId(uiOrder.getOrderId());
        order.setCreateDate(uiOrder.getCreateDate());
        order.setStartDate(uiOrder.getStartDate());
        order.setEndDate(uiOrder.getEndDate());
        order.setDesStartDate(uiOrder.getDesStartDate());
        order.setDesEndDate(uiOrder.getDesEndDate());
        order.setEngineerId(uiOrder.getEngineerId());
        order.setCustomerId(uiOrder.getCustomerId());
        order.setCommentary(uiOrder.getCommentary());
        order.setStateId(uiOrder.getStateId());
        order.setStateName(uiOrder.getStateName());
        order.setCustomerName(uiOrder.getCustomerName());
        order.setEngineerName(uiOrder.getEngineerName());
        order.setCustomerAddress(uiOrder.getCustomerAddress());
        return order;
    }

    public static UICustomer createFromCustomer(Customer customer) {
        UICustomer uiCustomer = new UICustomer();
        uiCustomer.setCustomerId(customer.getCustomerId());
        uiCustomer.setFirstName(customer.getFirstName());
        uiCustomer.setLastName(customer.getLastName());
        uiCustomer.setAddress(customer.getAddress());
        uiCustomer.setEmail(customer.getEmail());
        uiCustomer.setPhone(customer.getPhone());
        return uiCustomer;
    }

    public static UIEquipment createFromEquipment(Equipment equipment) {
        UIEquipment uiEquipment = new UIEquipment();
        uiEquipment.setEquipmentId(equipment.getEquipmentId());
        uiEquipment.setName(equipment.getName());
        uiEquipment.setIsParent(equipment.getIsParent());
        uiEquipment.setParentId(equipment.getParentId());
        uiEquipment.setDescription(equipment.getDescription());
        return uiEquipment;
    }

    public static Equipment createFromUIEquipment(UIEquipment uiEquipment) {
        Equipment equipment = new Equipment();
        equipment.setEquipmentId(uiEquipment.getEquipmentId());
        equipment.setName(uiEquipment.getName());
        equipment.setDescription(uiEquipment.getDescription());
        equipment.setIsParent(uiEquipment.getIsParent());
        equipment.setParentId(uiEquipment.getParentId());
        return equipment;
    }

    public static UIHistory createFromHistory(History history) {
        UIHistory uiHistory = new UIHistory();
        uiHistory.setHistoryId(history.getHistoryId());
        uiHistory.setNewState(history.getNewState());
        uiHistory.setChangeDate(history.getChangeDate());
        uiHistory.setCommentary(history.getCommentary());
        uiHistory.setOrderId(history.getOrderId());
        uiHistory.setStaffId(history.getStaffId());
        uiHistory.setNewStateName(history.getNewStateName());
        uiHistory.setStaffName(history.getStaffName());
        return uiHistory;
    }

    public static History createFromUIHistory(UIHistory uiHistory) {
        History history = new History();
        history.setHistoryId(uiHistory.getHistoryId());
        history.setNewState(uiHistory.getNewState());
        history.setChangeDate(uiHistory.getChangeDate());
        history.setCommentary(uiHistory.getCommentary());
        history.setOrderId(uiHistory.getOrderId());
        history.setStaffId(uiHistory.getStaffId());
        history.setNewStateName(uiHistory.getNewStateName());
        history.setStaffName(uiHistory.getStaffName());
        return history;
    }

    public static UIOrder createFromOrder(Order order) {
        UIOrder uiOrder = new UIOrder();
        uiOrder.setOrderId(order.getOrderId());
        uiOrder.setCreateDate(order.getCreateDate());
        uiOrder.setStartDate(order.getStartDate());
        uiOrder.setEndDate(order.getEndDate());
        uiOrder.setDesStartDate(order.getDesStartDate());
        uiOrder.setDesEndDate(order.getDesEndDate());
        uiOrder.setEngineerId(order.getEngineerId());
        uiOrder.setCustomerId(order.getCustomerId());
        uiOrder.setCommentary(order.getCommentary());
        uiOrder.setStateId(order.getStateId());
        uiOrder.setStateName(order.getStateName());
        uiOrder.setCustomerName(order.getCustomerName());
        uiOrder.setEngineerName(order.getEngineerName());
        uiOrder.setCustomerAddress(order.getCustomerAddress());
        return uiOrder;
    }

    public static UIOrderServEquip createFromOrderServEquip(OrderServEquip orderServEquip) {
        UIOrderServEquip uiOrderServEquip = new UIOrderServEquip();
        uiOrderServEquip.setOrderId(orderServEquip.getOrderId());
        uiOrderServEquip.setServEquipId(orderServEquip.getServEquipId());
        return uiOrderServEquip;
    }

    public static OrderServEquip createFromUIOrderServEquip(UIOrderServEquip uiOrderServEquip) {
        OrderServEquip orderServEquip = new OrderServEquip();
        orderServEquip.setOrderId(uiOrderServEquip.getOrderId());
        orderServEquip.setServEquipId(uiOrderServEquip.getServEquipId());
        return orderServEquip;
    }

    public static UIPosition createFromPosition(Position position) {
        UIPosition uiPosition = new UIPosition();
        uiPosition.setPositionId(position.getPositionId());
        uiPosition.setName(position.getName());
        return uiPosition;
    }

    public static UIRefs createFromRefs(Refs refs) {
        UIRefs uiRefs = new UIRefs();
        uiRefs.setEquipmentId(refs.getEquipmentId());
        uiRefs.setServiceId(refs.getServiceId());
        return uiRefs;
    }

    public static UIService createFromService(Service service) {
        UIService uiService = new UIService();
        uiService.setServiceId(service.getServiceId());
        uiService.setName(service.getName());
        uiService.setIsParent(service.getIsParent());
        uiService.setParentId(service.getParentId());
        uiService.setDescription(service.getDescription());
        return uiService;
    }

    public static Service createFromUIService(UIService uiService) {
        Service service = new Service();
        service.setServiceId(uiService.getServiceId());
        service.setName(uiService.getName());
        service.setDescription(uiService.getDescription());
        service.setIsParent(uiService.getIsParent());
        service.setParentId(uiService.getParentId());
        return service;
    }

    public static UIStaff createFromStaff(Staff staff) {
        UIStaff uiStaff = new UIStaff();
        uiStaff.setStaffId(staff.getStaffId());
        uiStaff.setFirstName(staff.getFirstName());
        uiStaff.setLastName(staff.getLastName());
        uiStaff.setPassword(staff.getPassword());
        uiStaff.setEmail(staff.getEmail());
        uiStaff.setPositionId(staff.getPositionId());
        return uiStaff;
    }

    public static UIState createFromState(State state) {
        UIState uiState = new UIState();
        uiState.setStateId(state.getStateId());
        uiState.setName(state.getName());
        return uiState;
    }

    public static Refs createFromUIRefs(UIRefs uiRefs) {
        Refs refs = new Refs();
        refs.setServiceId(uiRefs.getServiceId());
        refs.setEquipmentId(uiRefs.getEquipmentId());
        return refs;
    }

    public static UIImportOrder createFromImportOrder(ImportOrder importOrder) {
        UIImportOrder uiImportOrder = new UIImportOrder();
        uiImportOrder.setCustomerName(importOrder.getCustomerName());
        uiImportOrder.setCustomerAddress(importOrder.getCustomerAddress());
        uiImportOrder.setCustomerPhone(importOrder.getCustomerPhone());
        uiImportOrder.setCustomerEmail(importOrder.getCustomerEmail());
        uiImportOrder.setDesirableStart(importOrder.getDesirableStart());
        uiImportOrder.setDesirableEnd(importOrder.getDesirableEnd());
        uiImportOrder.setCommentary(importOrder.getCommentary());
        return uiImportOrder;
    }

    public static ImportOrder createFromUIImportOrder(UIImportOrder uiImportOrder) {
        ImportOrder importOrder = new ImportOrder();
        importOrder.setCustomerName(uiImportOrder.getCustomerName());
        importOrder.setCustomerAddress(uiImportOrder.getCustomerAddress());
        importOrder.setCustomerPhone(uiImportOrder.getCustomerPhone());
        importOrder.setCustomerEmail(uiImportOrder.getCustomerEmail());
        importOrder.setDesirableStart(uiImportOrder.getDesirableStart());
        importOrder.setDesirableEnd(uiImportOrder.getDesirableEnd());
        importOrder.setCommentary(uiImportOrder.getCommentary());
        return importOrder;
    }
}
